﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponents.Data.Query;

namespace ProgNetComponents.Design.Editors
{
    public class SelectDataCollectionEditor : ProgNetComponents.Design.Editors.NamedCollectionEditor
    {
        public SelectDataCollectionEditor(Type t) : base(t) { }
        
        protected override bool GenerateConstantClass
        {
            get
            {
                return true;
            }
        }

        protected override void ValidateCollection(object collection)
        {
            SelectDataCollection coll = collection as SelectDataCollection;
            if (coll != null)
            {
                List<string> names = new List<string>();
                foreach (SelectData d in coll)
                {
                    if (d.Name.IsNull())
                    {
                        AddError("At least one item does not have Name");
                    }
                    else if (d.MultiRecordQueries.Count == 0 && d.SingleRecordQueries.Count == 0)
                        AddError("SelectData " + d.Name.AddDoubleQuotes() + " does not have any queries");
                }
            }
        }
    }
}
